<?php

class CLocaleAR extends CActiveRecord
{
	
	public function beforeSave()
	{
		if(parent::beforeSave()){
			foreach ($this->metaData->columns as $column){
				switch ($column->dbType){
					case 'date':
						$this->{$column->name}=date('Y-m-d',strtotime($this->{$column->name}));
						break;
					case 'datetime':
						$this->{$column->name}=date('Y-m-d H:i:s',strtotime($this->{$column->name}));
						break;
					case 'timestamp':
						$this->{$column->name}=date('Y-m-d H:i:s',$this->{$column->name});
						break;
				}
			}
		}
		else
			return true;
	}
	
}